home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ADA Programming Guide
/
ADA Programming Guide.iso
/
ada_pcdp
/
ada
/
workers.ada
< prev
Wrap
Text File
|
1996-01-30
|
682b
|
26 lines
separate(MatrixL)
task body Workers is
Next, Row_Tuple, Col_Tuple: Tuples;
Element, I, J, Sum: Integer;
begin
loop
Next := In_Tuple(Char('N'), Formal_Int);
Element := Int(Next, 2);
Out_Tuple(Char('N'), Int(Element+1));
exit when Element > 3 * 3;
I := (Element - 1) / 3 + 1;
J := (Element - 1) mod 3 + 1;
Row_Tuple := Read_Tuple(Char('A'), Int(I), Formal_Vec);
Col_Tuple := Read_Tuple(Char('B'), Int(J), Formal_Vec);
Sum := 0;
for N in 1..3 loop
Sum := Sum + Vec(Row_Tuple,3)(N) * Vec(Col_Tuple,3)(N);
end loop;
Out_Tuple(Char('C'), Int(I), Int(J), Int(Sum));
end loop;
end Workers;